[Unit]
Description=PostgreSQL {{ pg_version }} database server
Documentation=https://www.postgresql.org/docs/{{ pg_version }}/static/
After=syslog.target
After=network.target

[Service]
LimitNOFILE=16777216
LimitNPROC=infinity
LimitCORE=infinity
Type=notify
User={{ pg_dbsu }}
Group=postgres
Environment=PGDATA={{ pg_data | default('/pg/data') }}
OOMScoreAdjust=-1000
Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
Environment=PG_OOM_ADJUST_VALUE=0

ExecStartPre=/usr/pgsql-{{ pg_version }}/bin/postgresql-{{ pg_version }}-check-db-dir ${PGDATA}
ExecStart=/usr/pgsql-{{ pg_version }}/bin/postmaster -D ${PGDATA}
ExecReload=/bin/kill -HUP $MAINPID
KillMode=mixed
KillSignal=SIGINT
TimeoutSec=0


[Install]
WantedBy=multi-user.target